<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AJAX</title>
</head>

<body>
    <input type="text" id="int1">
    <input type="text" id="int2">
    <input type="text" id="int3">
    <button id="btn">注册</button>
</body>
<script>
    //     用户注册 

    // ​		接口地址： https://liu.zzgoodqc.cn/register  POST

    // ​		注册数据字段： username,password,email

    // ​		根据输入不同得数据，返回信息经行弹窗提示


    window.onload = function () {


        document.getElementById('btn').onclick = function () {
            var username = document.getElementById('int1').value,
                password = document.getElementById('int2').value,
                email = document.getElementById('int3').value
            console.log(username,password,email);

            var xhttp = new XMLHttpRequest()
            xhttp.open('POST', 'https://liu.zzgoodqc.cn/register', true)
            xhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded')
            xhttp.onreadystatechange = function () {
                if (xhttp.readyState == 4 && xhttp.status == 200) {
                    var dataobj = JSON.parse(xhttp.responseText)
                    console.log(1);
                    // if (xhttp.code == 200 && xhttp.status == 4) {
                    //     alert(dataobj.msg)
                    // } else {
                    //     alert(dataobj.msg)
                    // }
                }
            }


            var data = 'username=' + username + '&password=' + password + '&email=' + email

            xhttp.send(data)
        }
    }

    

</script>

</html>